import request from "@/utils/request";

export function getRolePageList(data) {
    return request({
        url: '/uum-admin/api/v1/role/page',
        method: 'get',
        params: data
    })
}

export function getRoleList() {
    return request({
        url: '/uum-admin/api/v1/role/select',
        method: 'get'
    })
}

export function listByRole(id) {
    return request({
        url: '/uum-admin/api/v1/role/listByRole/'+ id,
        method: 'get',
    })
}

export function addRole(data) {
    return request({
        url: '/uum-admin/api/v1/role/add',
        method: 'post',
        data
    })
}

export function updateRole(data) {
    return request({
        url: '/uum-admin/api/v1/role/update',
        method: 'put',
        data
    })
}

export function roleDetail(id) {
    return request({
        url: '/uum-admin/api/v1/role/detail/' + id,
        method: 'get',
    })
}

export function deleteRole(ids) {
    return request({
        url: '/uum-admin/api/v1/role/delete/'+ids,
        method: 'delete',
    })
}

export function updateRoleMenu(id, menuIds) {
    return request({
        url: '/uum-admin/api/v1/role/' + id + '/menu',
        method: 'put',
        data: {menuIdList: menuIds}
    })
}


export function listRolePermission(id, params) {
    return request({
        url: '/uum-admin/api/v1/role/' + id + '/permissions',
        method: 'get',
        params: params
    })
}



export function updateRolePermission(menuId, roleId, permissionIds) {
    return request({
        url: '/uum-admin/api/v1/role/' + roleId + '/permissions',
        method: 'put',
        data: {menuId: menuId, permissionIds: permissionIds}
    })
}

